-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngMock): add sharedInjector() to angular.mock.module #14093
Conversation
I'll review this later this week. Thanks |
* ## Example | ||
* | ||
* Typically beforeAll is used to make many assertions about a single operation. This can | ||
* cut down test run-tims, and produce focussed tests with a single assertion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run-time
@timruffles - nice one Tim! A couple of minor documentation points to deal with but it seems good to me. I think it is also worth updating the testing guide with this new feature (https://docs.angularjs.org/guide/unit-testing) |
b7e754a
to
8b44322
Compare
@petebacondarwin thanks for reviewing. Have updated docs as per your suggestions, and added a section to guide. The fiddles are also updated. |
Can you run |
8b44322
to
ca47210
Compare
Allow to opt-in to using a shared injector within a context. This allows hooks to be used in Jasmine 2.x.x/Mocha
ca47210
to
d9d56e9
Compare
@petebacondarwin Yup, fixed! Sorry about that. |
Just ran into this bug today and am delighted to see the fix is in. Thanks @timruffles ! 👍 |
@petebacondarwin let me know if there's anything else you like me to do on this! |
No problem. I'll deal with it today |
Allows users to opt-in to using a shared injector within a
describe()
context, viaangular.mock.module.sharedInjector()
.This enables Jasmine 2.x/mocha's
beforeAll()
/before()
hooks to be used with Angular, fixing issue #10238 as previously discussed.Beyond the tests added to
angular-mocksSpec.js
, I've also created JSFiddles with the new behaviour working alongside:The verification tests above contain tests suggested by @lgalfaso. cc/@petebacondarwin. The unit tests added contain a little test framework stub, as it was nigh on impossible to test this feature without interference from the rest of the Angular test machinery. Testing inception!